home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
tools
/
czesc_1
/
cpdist
/
keys.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-12
|
1KB
|
74 lines
/*
* KEYS.C
*/
/*
* (c)Copyright 1992-93 by Tobias Ferber.
*
* This file is part of CPDIST.
*
* CPDIST is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 1 of the License,
* or (at your option) any later version.
*
* CPDIST is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CPDIST; see the file COPYING. If not, write to
* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <ctype.h>
typedef struct lnode {
struct lnode *next;
char *key;
} lnode;
static lnode *ln_head= (lnode *)0L;
ln_equals(char *s, char *t)
{
while(*s && *t && toupper(*s)==toupper(*t))
{ ++s;
++t;
}
return ((*s && *s!=':') || (*t && *t!=':')) ? 0:1;
}
int ln_member(char *key)
{
lnode *n;
for(n= ln_head; n && !ln_equals(n->key,key); n= n->next);
return n ? 1 : 0;
}
int ln_addnode(char *key)
{
lnode *n;
if(n= (lnode *)malloc(sizeof(lnode)))
{
n->next= ln_head;
ln_head= n;
n->key = key;
}
return n ? 1:0;
}
void ln_purge(void)
{
lnode *n= ln_head;
while(n)
{ lnode *t= n;
n= n->next;
free(t);
}
}